package org.spiderflow.core.expression.parsing.ast.literal;

import org.spiderflow.core.expression.ExpressionTemplate;
import org.spiderflow.core.expression.ExpressionTemplateContext;
import org.spiderflow.core.expression.parsing.Span;
import org.spiderflow.core.expression.parsing.ast.Expression;

import java.io.IOException;

/**
 * An integer literal.
 *
 * @author zsh
 */
public class IntegerLiteral extends Expression {
    private final Integer value;

    public IntegerLiteral(Span literal) {
        super(literal);
        this.value = Integer.parseInt(literal.getText());
    }

    public Integer getValue() {
        return value;
    }

    @Override
    public Object evaluate(ExpressionTemplate template, ExpressionTemplateContext context) throws IOException {
        return value;
    }
}
